<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>wickr-crypto-c: src/wickrcrypto/include/wickrcrypto/stream_ctx.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">wickr-crypto-c
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.15 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_92a70b6cc7e213c660915fdf1190028f.html">wickrcrypto</a></li><li class="navelem"><a class="el" href="dir_db4377ef08cfba82f5e7141624102360.html">include</a></li><li class="navelem"><a class="el" href="dir_2adb4122f2f58e588d09641dee9865e2.html">wickrcrypto</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">stream_ctx.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/*</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> * Copyright © 2012-2018 Wickr Inc.  All rights reserved.</span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * This code is being released for EDUCATIONAL, ACADEMIC, AND CODE REVIEW PURPOSES</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> * ONLY.  COMMERCIAL USE OF THE CODE IS EXPRESSLY PROHIBITED.  For additional details,</span></div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> * please see LICENSE</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment"> * THE CODE IS MADE AVAILABLE &quot;AS-IS&quot; AND WITHOUT ANY EXPRESS OR</span></div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment"> * IMPLIED GUARANTEES AS TO FITNESS, MERCHANTABILITY, NON-</span></div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment"> * INFRINGEMENT OR OTHERWISE. IT IS NOT BEING PROVIDED IN TRADE BUT ON</span></div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment"> * A VOLUNTARY BASIS ON BEHALF OF THE AUTHOR’S PART FOR THE BENEFIT</span></div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment"> * OF THE LICENSEE AND IS NOT MADE AVAILABLE FOR CONSUMER USE OR ANY</span></div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment"> * OTHER USE OUTSIDE THE TERMS OF THIS LICENSE. ANYONE ACCESSING THE</span></div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment"> * CODE SHOULD HAVE THE REQUISITE EXPERTISE TO SECURE THEIR SYSTEM</span></div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment"> * AND DEVICES AND TO ACCESS AND USE THE CODE FOR REVIEW PURPOSES</span></div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment"> * ONLY. LICENSEE BEARS THE RISK OF ACCESSING AND USING THE CODE. IN</span></div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="comment"> * PARTICULAR, AUTHOR BEARS NO LIABILITY FOR ANY INTERFERENCE WITH OR</span></div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="comment"> * ADVERSE EFFECT THAT MAY OCCUR AS A RESULT OF THE LICENSEE</span></div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="comment"> * ACCESSING AND/OR USING THE CODE ON LICENSEE’S SYSTEM.</span></div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="comment"> */</span></div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;</div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="preprocessor">#ifndef stream_ctx_h</span></div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="preprocessor">#define stream_ctx_h</span></div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="preprocessor">#include &quot;crypto_engine.h&quot;</span></div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="preprocessor">#include &quot;stream_iv.h&quot;</span></div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="preprocessor">#include &quot;stream_key.h&quot;</span></div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;</div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="preprocessor">#ifdef __cplusplus</span></div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;<span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="keyword">typedef</span> <span class="keyword">enum</span> { STREAM_DIRECTION_ENCODE, STREAM_DIRECTION_DECODE } wickr_stream_direction;</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;</div><div class="line"><a name="l00067"></a><span class="lineno"><a class="line" href="structwickr__stream__ctx.html">   67</a></span>&#160;<span class="keyword">struct </span><a class="code" href="structwickr__stream__ctx.html">wickr_stream_ctx</a> {</div><div class="line"><a name="l00068"></a><span class="lineno"><a class="line" href="structwickr__stream__ctx.html#a14ef322bbeec579ded7f35c5aeb0d3fa">   68</a></span>&#160;    <a class="code" href="structwickr__crypto__engine.html">wickr_crypto_engine_t</a> <a class="code" href="structwickr__stream__ctx.html#a14ef322bbeec579ded7f35c5aeb0d3fa">engine</a>;</div><div class="line"><a name="l00069"></a><span class="lineno"><a class="line" href="structwickr__stream__ctx.html#a3598b3c0415d13fafab6633f8c00a3c8">   69</a></span>&#160;    <a class="code" href="structwickr__stream__key.html">wickr_stream_key_t</a> *<a class="code" href="structwickr__stream__ctx.html#a3598b3c0415d13fafab6633f8c00a3c8">key</a>;</div><div class="line"><a name="l00070"></a><span class="lineno"><a class="line" href="structwickr__stream__ctx.html#a67c5066e87dbdc026358563daa51f174">   70</a></span>&#160;    <a class="code" href="structwickr__stream__iv.html">wickr_stream_iv_t</a> *<a class="code" href="structwickr__stream__ctx.html#a67c5066e87dbdc026358563daa51f174">iv_factory</a>;</div><div class="line"><a name="l00071"></a><span class="lineno"><a class="line" href="structwickr__stream__ctx.html#abf2c6ab54e1663e6a47e310fd68b3b3f">   71</a></span>&#160;    uint64_t <a class="code" href="structwickr__stream__ctx.html#abf2c6ab54e1663e6a47e310fd68b3b3f">last_seq</a>;</div><div class="line"><a name="l00072"></a><span class="lineno"><a class="line" href="structwickr__stream__ctx.html#a34c622c3ca61348321261ee7a9c3ff91">   72</a></span>&#160;    wickr_stream_direction <a class="code" href="structwickr__stream__ctx.html#a34c622c3ca61348321261ee7a9c3ff91">direction</a>;</div><div class="line"><a name="l00073"></a><span class="lineno"><a class="line" href="structwickr__stream__ctx.html#aa0e74b2c117666501373a5947d92e8c4">   73</a></span>&#160;    <span class="keywordtype">size_t</span> <a class="code" href="structwickr__stream__ctx.html#aa0e74b2c117666501373a5947d92e8c4">ref_count</a>;</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;};</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;</div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;<span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structwickr__stream__ctx.html">wickr_stream_ctx</a> <a class="code" href="structwickr__stream__ctx.html">wickr_stream_ctx_t</a>;</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;</div><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;<a class="code" href="structwickr__stream__ctx.html">wickr_stream_ctx_t</a> *<a class="code" href="group__wickr__stream.html#ga0b5c513a3e0958dc7fd4f8455206e32e">wickr_stream_ctx_create</a>(<span class="keyword">const</span> <a class="code" href="structwickr__crypto__engine.html">wickr_crypto_engine_t</a> <a class="code" href="structwickr__stream__ctx.html#a14ef322bbeec579ded7f35c5aeb0d3fa">engine</a>, <a class="code" href="structwickr__stream__key.html">wickr_stream_key_t</a> *stream_key, wickr_stream_direction <a class="code" href="structwickr__stream__ctx.html#a34c622c3ca61348321261ee7a9c3ff91">direction</a>);</div><div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;</div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;<a class="code" href="structwickr__stream__ctx.html">wickr_stream_ctx_t</a> *<a class="code" href="group__wickr__stream.html#ga707b685e35eb437c33f5ec32c6760005">wickr_stream_ctx_copy</a>(<span class="keyword">const</span> <a class="code" href="structwickr__stream__ctx.html">wickr_stream_ctx_t</a> *ctx);</div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;</div><div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;<a class="code" href="structwickr__cipher__result.html">wickr_cipher_result_t</a> *<a class="code" href="group__wickr__stream.html#ga621a3ec801ab996b4fab1fe905c450bd">wickr_stream_ctx_encode</a>(<a class="code" href="structwickr__stream__ctx.html">wickr_stream_ctx_t</a> *ctx, <span class="keyword">const</span> <a class="code" href="structwickr__buffer.html">wickr_buffer_t</a> *data, <span class="keyword">const</span> <a class="code" href="structwickr__buffer.html">wickr_buffer_t</a> *aad, uint64_t seq_num);</div><div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;</div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;<a class="code" href="structwickr__buffer.html">wickr_buffer_t</a> *<a class="code" href="group__wickr__stream.html#gaa1eb323694f2c1652b51127b0b89138c">wickr_stream_ctx_decode</a>(<a class="code" href="structwickr__stream__ctx.html">wickr_stream_ctx_t</a> *ctx, <span class="keyword">const</span> <a class="code" href="structwickr__cipher__result.html">wickr_cipher_result_t</a> *data, <span class="keyword">const</span> <a class="code" href="structwickr__buffer.html">wickr_buffer_t</a> *aad, uint64_t seq_num);</div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;</div><div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;<span class="keywordtype">void</span> <a class="code" href="group__wickr__stream.html#ga05260bfce1f50352cad32e0354c28a1d">wickr_stream_ctx_destroy</a>(<a class="code" href="structwickr__stream__ctx.html">wickr_stream_ctx_t</a> **ctx);</div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;</div><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;<span class="keywordtype">bool</span> <a class="code" href="group__wickr__stream.html#ga98121b9f8cdab6596cbd3bb0d99be6e3">wickr_stream_ctx_ref_up</a>(<a class="code" href="structwickr__stream__ctx.html">wickr_stream_ctx_t</a> *ctx);</div><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;</div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;<span class="preprocessor">#ifdef __cplusplus</span></div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;}</div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;</div><div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;<span class="preprocessor">#endif </span><span class="comment">/* stream_ctx_h */</span><span class="preprocessor"></span></div><div class="ttc" id="group__wickr__stream_html_ga05260bfce1f50352cad32e0354c28a1d"><div class="ttname"><a href="group__wickr__stream.html#ga05260bfce1f50352cad32e0354c28a1d">wickr_stream_ctx_destroy</a></div><div class="ttdeci">void wickr_stream_ctx_destroy(wickr_stream_ctx_t **ctx)</div></div>
<div class="ttc" id="structwickr__stream__ctx_html_a67c5066e87dbdc026358563daa51f174"><div class="ttname"><a href="structwickr__stream__ctx.html#a67c5066e87dbdc026358563daa51f174">wickr_stream_ctx::iv_factory</a></div><div class="ttdeci">wickr_stream_iv_t * iv_factory</div><div class="ttdef"><b>Definition:</b> stream_ctx.h:70</div></div>
<div class="ttc" id="group__wickr__stream_html_ga621a3ec801ab996b4fab1fe905c450bd"><div class="ttname"><a href="group__wickr__stream.html#ga621a3ec801ab996b4fab1fe905c450bd">wickr_stream_ctx_encode</a></div><div class="ttdeci">wickr_cipher_result_t * wickr_stream_ctx_encode(wickr_stream_ctx_t *ctx, const wickr_buffer_t *data, const wickr_buffer_t *aad, uint64_t seq_num)</div></div>
<div class="ttc" id="structwickr__buffer_html"><div class="ttname"><a href="structwickr__buffer.html">wickr_buffer</a></div><div class="ttdoc">Represents an array of bytes and the length of the allocation associated with those bytes.</div><div class="ttdef"><b>Definition:</b> buffer.h:51</div></div>
<div class="ttc" id="structwickr__stream__ctx_html_abf2c6ab54e1663e6a47e310fd68b3b3f"><div class="ttname"><a href="structwickr__stream__ctx.html#abf2c6ab54e1663e6a47e310fd68b3b3f">wickr_stream_ctx::last_seq</a></div><div class="ttdeci">uint64_t last_seq</div><div class="ttdef"><b>Definition:</b> stream_ctx.h:71</div></div>
<div class="ttc" id="structwickr__stream__ctx_html"><div class="ttname"><a href="structwickr__stream__ctx.html">wickr_stream_ctx</a></div><div class="ttdoc">A context that is used for encrypting or decrypting a sequenced stream of data packets The stream con...</div><div class="ttdef"><b>Definition:</b> stream_ctx.h:67</div></div>
<div class="ttc" id="group__wickr__stream_html_gaa1eb323694f2c1652b51127b0b89138c"><div class="ttname"><a href="group__wickr__stream.html#gaa1eb323694f2c1652b51127b0b89138c">wickr_stream_ctx_decode</a></div><div class="ttdeci">wickr_buffer_t * wickr_stream_ctx_decode(wickr_stream_ctx_t *ctx, const wickr_cipher_result_t *data, const wickr_buffer_t *aad, uint64_t seq_num)</div></div>
<div class="ttc" id="structwickr__stream__iv_html"><div class="ttname"><a href="structwickr__stream__iv.html">wickr_stream_iv</a></div><div class="ttdoc">A deterministic random IV generator using a 64 byte secure random seed and HMAC-SHA512.</div><div class="ttdef"><b>Definition:</b> stream_iv.h:53</div></div>
<div class="ttc" id="structwickr__stream__key_html"><div class="ttname"><a href="structwickr__stream__key.html">wickr_stream_key</a></div><div class="ttdoc">A data structure representing the stream encoding / decoding key material A stream key holds informat...</div><div class="ttdef"><b>Definition:</b> stream_key.h:56</div></div>
<div class="ttc" id="structwickr__cipher__result_html"><div class="ttname"><a href="structwickr__cipher__result.html">wickr_cipher_result</a></div><div class="ttdef"><b>Definition:</b> cipher.h:97</div></div>
<div class="ttc" id="structwickr__stream__ctx_html_a34c622c3ca61348321261ee7a9c3ff91"><div class="ttname"><a href="structwickr__stream__ctx.html#a34c622c3ca61348321261ee7a9c3ff91">wickr_stream_ctx::direction</a></div><div class="ttdeci">wickr_stream_direction direction</div><div class="ttdef"><b>Definition:</b> stream_ctx.h:72</div></div>
<div class="ttc" id="structwickr__stream__ctx_html_a3598b3c0415d13fafab6633f8c00a3c8"><div class="ttname"><a href="structwickr__stream__ctx.html#a3598b3c0415d13fafab6633f8c00a3c8">wickr_stream_ctx::key</a></div><div class="ttdeci">wickr_stream_key_t * key</div><div class="ttdef"><b>Definition:</b> stream_ctx.h:69</div></div>
<div class="ttc" id="group__wickr__stream_html_ga98121b9f8cdab6596cbd3bb0d99be6e3"><div class="ttname"><a href="group__wickr__stream.html#ga98121b9f8cdab6596cbd3bb0d99be6e3">wickr_stream_ctx_ref_up</a></div><div class="ttdeci">bool wickr_stream_ctx_ref_up(wickr_stream_ctx_t *ctx)</div></div>
<div class="ttc" id="structwickr__stream__ctx_html_a14ef322bbeec579ded7f35c5aeb0d3fa"><div class="ttname"><a href="structwickr__stream__ctx.html#a14ef322bbeec579ded7f35c5aeb0d3fa">wickr_stream_ctx::engine</a></div><div class="ttdeci">wickr_crypto_engine_t engine</div><div class="ttdef"><b>Definition:</b> stream_ctx.h:68</div></div>
<div class="ttc" id="group__wickr__stream_html_ga0b5c513a3e0958dc7fd4f8455206e32e"><div class="ttname"><a href="group__wickr__stream.html#ga0b5c513a3e0958dc7fd4f8455206e32e">wickr_stream_ctx_create</a></div><div class="ttdeci">wickr_stream_ctx_t * wickr_stream_ctx_create(const wickr_crypto_engine_t engine, wickr_stream_key_t *stream_key, wickr_stream_direction direction)</div></div>
<div class="ttc" id="structwickr__crypto__engine_html"><div class="ttname"><a href="structwickr__crypto__engine.html">wickr_crypto_engine</a></div><div class="ttdoc">Interface to a set of cryptographic operations used throughout the library. Currently the default imp...</div><div class="ttdef"><b>Definition:</b> crypto_engine.h:53</div></div>
<div class="ttc" id="structwickr__stream__ctx_html_aa0e74b2c117666501373a5947d92e8c4"><div class="ttname"><a href="structwickr__stream__ctx.html#aa0e74b2c117666501373a5947d92e8c4">wickr_stream_ctx::ref_count</a></div><div class="ttdeci">size_t ref_count</div><div class="ttdef"><b>Definition:</b> stream_ctx.h:73</div></div>
<div class="ttc" id="group__wickr__stream_html_ga707b685e35eb437c33f5ec32c6760005"><div class="ttname"><a href="group__wickr__stream.html#ga707b685e35eb437c33f5ec32c6760005">wickr_stream_ctx_copy</a></div><div class="ttdeci">wickr_stream_ctx_t * wickr_stream_ctx_copy(const wickr_stream_ctx_t *ctx)</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.15
</small></address>
</body>
</html>
